package com.day1013.morning;

public class Climb extends Thread {
    private int time;//  休眠时间，爬完100米需要的时间
    private int num;//  爬几个100米，计算得出

    /**
     *@param：name 线程名
     * @param：time 时间
     * @param：kilometer 总路程
     */
    public Climb (String name,int time,int kilometer){
        super.setName(name);
        this.time = time;
        this.num = kilometer * 1000 / 100;
    }

    @Override
    public void run() {
        while (num > 0){
            try {
                Thread.sleep(this.time);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(this.getName() + "爬完了100米！");
            num--;
        }
        System.out.println(this.getName() + "爬到山顶");
    }
}
